#ifndef _MS_SPHERE_H_
#include <math.h>
//--- #include <stdlib.h>
#include <stdio.h>
//--- #include <string.h>
//--- #include <iostream>

#include "ms_voxelimage.h"

class sphere;

class sphere {
	public:
		double X[3], R, coreR;
		// coreR == R/2 by default
	public:
		sphere( const double r=1. );
		sphere( const double x[3], const double r=1.);
		
		inline void   Displace( const double dx[] ) { X[0]+=dx[0]; X[1]+=dx[1]; X[2]+=dx[2]; }
		inline void   MoveTo( const double xx[] )   { X[0]=xx[0];  X[1]=xx[1];  X[2]=xx[2]; }
		inline void   SetRadius( const double r )   { R=r; }
		
		inline double GetXMin() const { return X[0]-R; }
		inline double GetXMax() const { return X[0]+R; }
		inline double GetYMin() const { return X[1]-R; }
		inline double GetYMax() const { return X[1]+R; }
		inline double GetZMin() const { return X[2]-R; }
		inline double GetZMax() const { return X[2]+R; }
		
		double	Distance(const sphere & s)  const ;
		bool	Collision(const sphere & s) const ;
		double	IntersectionVolume(const sphere & s) const ;
		
		void	DrawVoxelImage(	VoxelImage & vx_img,
						const unsigned char col = 1 ) const ;
};

#define _MS_SPHERE_H_
#endif /* _MS_SPHERE_H_ */
